
//TODO a(59)
function a59(module, exports, a) {
    var i = a(23), s = a(6), r = a(3), n = (a(2), a(21)), o = a(60), l = function (e) {
        this.contDom = e.dom.cont, this.parentEl = e.dom.parentEl, this.active = e.active, this.coreVideo = e.coreVideo
    };
    r.extend(l, i);
    var d = {
        init: function () {
            this.playerData = this.manager.playerData, this.nodes = {
                progressBar: this.parentEl.find(".progress_bar"),
                sliderBtn: this.parentEl.find(".hv_ico_playing"),
                currentBar: this.parentEl.find(".porgress_playback"),
                bufferBar: this.parentEl.find(".progress_download"),
                totalTimeTip: this.parentEl.find(".time_total"),
                currentTimeTip: this.parentEl.find(".time_cur"),
                barBg: this.parentEl.find(".hv_scroll_cnt")
            }, this.hideTotalTimeTipPercent = 0, this.totalTimeTipWidth = 0, this.isTotalTimeTipHide = !1, this.currentTimeTipPosition = "right", this.seekTime = null, this.duration = 0, this.sliderBtnWidth = 16, this.manager.listener.on(n.PLAY_STATE, function (e, t) {
                "init" == t && (this.duration = 0, this.seekTime = null), "init" != t && "ended" != t || this.setProgress(0)
            }, this), this.addEvent()
        }, addEvent: function () {
            this.manager.evt.on(n.EVENT.RESIZE, this.onResize, this), "PC" == this.playerData.interactiveType ? (this.nodes.barBg.on("click", this.onPrograssBarClick, this), s(document).on("keydown", this.onKeyDown, this), s(document).on("keyup", this.onKeyUp, this)) : (this.silderTouchable = new o(this.nodes.sliderBtn[0]), this.silderTouchable.on("touchstart", this.onSliderTouchStart, this), this.silderTouchable.on("touchmove", this.onSliderTouchMove, this), this.silderTouchable.on("touchend", this.onSliderTouchEnd, this)), this.manager.evt.on("vjs_durationChange", this.onSetDuration, this), this.manager.evt.on("vjs_updateSeekTime", function (e) {
                this.setProgress(e.args[0])
            }, this), this.manager.evt.on("vjs_timeupdate", this.onTimeUpdate, this)
        }, onResize: function () {
            this.progressBarWidth = this.nodes.progressBar.width(), this.progressBarOffset = this.nodes.progressBar.offset().left, this.hideTotalTimeTipPercent = (this.progressBarWidth - (this.totalTimeTipWidth || 0) - this.sliderBtnWidth) / this.progressBarWidth, this.toggleTotalTimeTip(), this.switchCurrentTimePosition(), parseFloat(this.nodes.currentBar[0].style.width) / 100 > 1 && this.setProgress(1, "percent")
        }, onTimeUpdate: function () {
            var e = this.manager.listener.get(n.PLAY_STATE);
            this.active.isDrag || "play" != e || this.setProgress()
        }, onSliderTouchStart: function (e) {
            var t = e.args[1];
            t.preventDefault(), this.diffX = e.args[0].startTouch.x - this.nodes.sliderBtn.offset().left;
            var a = this.manager.listener.get(n.PLAY_STATE);
            "pause" != a && this.manager.evt.trigger(n.EVENT.PLAYER_COMMAND, "pause"), document.body.focus(), document.onselectstart = function () {
                return !1
            }
        }, onSliderTouchMove: function (e) {
            this.active.isDrag = !0;
            var t = e.args[0].currentTouch.x - this.progressBarOffset - this.diffX, a = t / this.progressBarWidth;
            this.setProgress(a, "percent")
        }, onSliderTouchEnd: function () {
            this.active.isDrag = !1;
            var e = parseFloat(this.nodes.sliderBtn.getStyle("left")) / 100 * this.duration;
            this.manager.evt.trigger(n.EVENT.PLAYER_COMMAND, "seek", e), document.onselectstart = null
        }, onPrograssBarClick: function (e) {
            var t = (e.clientX - this.progressBarOffset - this.sliderBtnWidth / 2) / this.progressBarWidth;
            this.setProgress(t, "percent");
            var a = parseFloat(this.nodes.sliderBtn.getStyle("left")) / 100 * this.duration;
            this.manager.evt.trigger(n.EVENT.PLAYER_COMMAND, "seek", a)
        }, onKeyDown: function (e) {
            if (37 === e.keyCode || 39 === e.keyCode) {
                var t = this.manager.listener.get(n.PLAY_STATE);
                "pause" != t && this.manager.evt.trigger(n.EVENT.PLAYER_COMMAND, "pause"), null == this.seekTime && (this.seekTime = this.coreVideo.getCurrentTime()), this.seekTime = 37 == e.keyCode ? this.seekTime - 15 : this.seekTime + 15, this.seekTime = Math.max(0, this.seekTime), this.seekTime = Math.min(this.seekTime, this.duration), this.setProgress(this.seekTime)
            }
        }, onKeyUp: function (e) {
            null == this.seekTime || 37 !== e.keyCode && 39 !== e.keyCode || (this.manager.evt.trigger(n.EVENT.PLAYER_COMMAND, "seek", this.seekTime), this.seekTime = null)
        }, onSetDuration: function (e) {
            this.duration = e.args[0] || 0, this.nodes.totalTimeTip[0].innerHTML = r.formatTime(this.duration), this.nodes.totalTimeTip[0].style.display = "", this.isTotalTimeTipHide = !1, this.totalTimeTipWidth = this.nodes.totalTimeTip.width(), this.hideTotalTimeTipPercent = (this.progressBarWidth - this.totalTimeTipWidth - this.sliderBtnWidth) / this.progressBarWidth, this.toggleTotalTimeTip()
        }, toggleTotalTimeTip: function (e) {
            e = e || parseFloat(this.nodes.sliderBtn[0].style.left) / 100, e >= this.hideTotalTimeTipPercent ? this.isTotalTimeTipHide || (this.nodes.totalTimeTip[0].style.display = "none", this.isTotalTimeTipHide = !0) : this.isTotalTimeTipHide && (this.nodes.totalTimeTip[0].style.display = "", this.isTotalTimeTipHide = !1)
        }, setProgress: function (e, t) {
            var a, i;
            if (0 == this.duration) a = 0; else if ("percent" == t) a = e; else {
                if (i = parseInt("undefined" != typeof e ? e : this.coreVideo.getCurrentTime()), i == this.currentTime || i > this.duration)return;
                this.currentTime = i, a = i / this.duration
            }
            if (a = Math.max(0, a), a = Math.min(a, 1), i = i || a * this.duration || 0, this.nodes.currentTimeTip[0].innerHTML = r.formatTime(i), this.nodes.currentTimeTip[0].currentTime = i, this.toggleTotalTimeTip(a), this.switchCurrentTimePosition(a), a = 100 * a, this.nodes.sliderBtn[0].style.left = a + "%", this.nodes.currentBar[0].style.width = a + "%", this.nodes.currentTimeTip[0].style.left = a + "%", "undefined" == typeof e) {
                var s = this.coreVideo.getBuffered(), n = s / this.duration * 100;
                n = Math.max(n, 0), n = Math.min(n, 100), n = n && n > a ? n : a, this.nodes.bufferBar.setStyle("width", n + "%")
            }
        }, switchCurrentTimePosition: function (e) {
            e = "undefined" != typeof e ? e : parseFloat(this.nodes.sliderBtn[0].style.left) / 100, e * this.progressBarWidth > 45 ? "left" != this.currentTimeTipPosition && (this.nodes.currentTimeTip.setStyle("marginLeft", "-45px"), this.currentTimeTipPosition = "left") : "right" != this.currentTimeTipPosition && (this.nodes.currentTimeTip.setStyle("marginLeft", "22px"), this.currentTimeTipPosition = "right")
        }
    };
    r.merge(l.prototype, d), module.exports = l
}

